<div class=head>
    任务时间纪录表
</div>

<div class=area>
    <script src="/time.js"></script>
    <script src="/editTimeEntries.js"> </script>
    <script language="Javascript">
        <!--
        
        function setTime(rowcount){
            field = getTimeField("startTime", rowcount - 1);
            if (field.value == "") {
                field.value = formatDate(new Date(), "yyyy-MM-dd HH:mm");
                entryChanged();
                return;
            }
            field = getTimeField("endTime", rowcount - 1);
            if (field.value == "") {
                field.value = formatDate(new Date(), "yyyy-MM-dd HH:mm");
                entryChanged();
                return;
            }
        }
        
        function getTimeField(name, offset){
            name = name + "[" + offset + "]";
            for (i = 0; i < document.timelog.length; i++) {
                if (document.timelog[i].name == name) {
                    return document.timelog[i];
                }
            }
        }
        
        // -->
    </script>
    <%form_tag :action => 'timer_update', :id => @todo do %><input type="hidden" name="todo_id" value='<%= @todo %>'>
    <table class="objecttable" cellpadding="1">
        <tr>
            <th class="objecttable" nowrap>
Start Time
            </th>
            <th class="objecttable" nowrap>
End Time
            </th>
            <th class="objecttable">
                Description
            </th>
            <th class="objecttable">
                <img src="/images/delete.gif" border="0" alt="delete">
            </th>
        </tr>
		<%
			row = 0
        for timelog in @todo.timelogs
			row += 1 %>
        <tr>
            <td class="objecttable">
                <input type="text" size="12" name="startTime[<%=row%>]" value='<%= timelog.start_time %>' onchange='entryChanged()'/>
            </td>
            <td class="objecttable">
                <input type="text" size="16" name="endTime[<%=row%>]" value='<%= timelog.end_time %>' onchange='entryChanged()'/>
            </td>
            <td class="objecttable">
                <input type="text" size="50" name="description[<%=row%>]" value='<%=timelog.desc %>'>
            </td>
            <td align="center" class="objecttable">
                <input type="hidden" name="entryId[<%=row%>]" value='<%=timelog%>'>
               	<input type="checkbox" name="deleted[<%=row%>]" value="true" onChange="entryChanged()"/>
            </td>
        </tr>
		<% end #for loop  %>
        <tr>
            <td class="objecttable_buttons" nowrap colspan="9">                
				<input type="submit" name="submit" value="Update">&nbsp;
				<input type="button" name="reset" value="Reset" onclick="javascript: window.location.reload();">&nbsp;
				<input type="button" name="action" value="insert_time" onClick='setTime(<%=row%>)'> &nbsp;
            </td>
        </tr>
    </table><input type="hidden" name="rowcount" value='<%=row%>'>
<% end %>
	
</div>
